package com.example.controller;

import com.example.bean.Event;
import com.example.service.EventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "赛事管理模块", description = "赛事的查询、添加、删除")
@Controller
@RequestMapping("/Event")
public class EventController {

    @Autowired
    EventService eventService;

    @ApiOperation("赛事查询")   //接口描述
    @RequestMapping(value = "/select-Event", method = RequestMethod.GET)
    @ResponseBody
    public List<Event> selectEvent(@RequestParam("eventsName") String eventsName){
        return eventService.selectEvent(eventsName);
    }

    @ApiOperation("赛事创建（预告）")   //接口描述
    @RequestMapping(value = "/add-Event", method = RequestMethod.POST)
    @ResponseBody
    public void addEvent(@RequestBody Event event){
        eventService.addEvent(event);
    }

    @ApiOperation("赛事取消")   //接口描述
    @RequestMapping(value = "/delete-Event", method = RequestMethod.POST)
    @ResponseBody
    public void deleteEvent(@RequestParam("eventsId") int eventsId){
        eventService.deleteEvent(eventsId);
    }

    @ApiOperation("最近赛事")   //接口描述
    @RequestMapping(value = "/near", method = RequestMethod.GET)
    @ResponseBody
    public List<Event> near(){
        return eventService.selectEventNear();
    }
}
